package com.tdam2011.grupo06;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;

public class ActivityAcciones extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_activity_acciones);
        
        ImageButton button = (ImageButton) findViewById(R.id.imageButton7);

        button.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
        // TODO Auto-generated method stub
        crearDialogoAlerta().show();
        }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_activity_acciones, menu);
        return true;
    }
    
    private Dialog crearDialogoAlerta()
    {
	    AlertDialog.Builder builder = new AlertDialog.Builder(this);
	
	    final EditText input = new EditText(this);
	    
        builder.setView(input);
	    builder.setTitle("Registrar Usuario");
	    builder.setPositiveButton("Aceptar", new OnClickListener() {
	    	
	    public void onClick(DialogInterface dialog, int which) {
	    // TODO Auto-generated method stub
	    	String value = input.getText().toString().trim();
            Toast.makeText(getApplicationContext(), value,
                    Toast.LENGTH_SHORT).show();
	    dialog.cancel();
	    }
    });
	    
	    builder.setNegativeButton("Cancelar", new OnClickListener() {
	    	
		    public void onClick(DialogInterface dialog, int which) {
		    // TODO Auto-generated method stub
		    dialog.cancel();
		    }
	    });

    return builder.create();
    }
}
